#include "Device/delay/delay.h"

uint64_t tick;
//systick reload value to generate 1us interrupt
volatile uint32_t g_systickCounter;
void SysTick_Handler(void)
{
    tick += 1;
    if (g_systickCounter != 0U)
    {
        g_systickCounter--;
    }
}
void TickInit(){
     SystemCoreClockUpdate();
        if (SysTick_Config(SystemCoreClock / 1000000U))
    {
        while (1)
        {
        }
    }
}
void Delay_us(uint32_t n)
{
    g_systickCounter = n;
    while (g_systickCounter != 0U)
    {
    }
}
void Delay_ms(uint32_t n){
    Delay_us(n*1000);
}

uint64_t getTimeInUs(){return tick;}
